'use strict';

module.exports = app => {
  const { INTEGER, STRING } = app.Sequelize;

  const Conversation = app.model.define('conversation', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    news_content: STRING,
    type: { type: INTEGER, defaultValue: 3 }, // 1 已完结 2 处理中  3 待处理
    score: { type: INTEGER, defaultValue: 0 },
  });

  Conversation.associate = function() {
    app.model.Conversation.belongsTo(app.model.User, {
      targetKey: 'id',
      foreignKey: 'user_id',
    });

    app.model.Conversation.belongsTo(app.model.User, {
      targetKey: 'id',
      foreignKey: 'staff_id',
    });
  };

  return Conversation;
};
